Robustness fixes for drag cancel animation
authorMatthias Clasen <mclasen@redhat.com>
Fri, 30 Jan 2015 11:07:34 +0000 (06:07 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 30 Jan 2015 15:13:29 +0000 (10:13 -0500)
gtk_widget_get_frame_clock() can return NULL. Deal with that
by silently stopping the drag cancel animation in this case.

gtk/gtkdnd.c

index 6e829d14ed43b6d49d0138368f9576b06dd83a12..733af5e398ca3b6638146b6fb123e4f12ac138e6 100644 (file)
@@ -3942,16 +3942,24 @@ gtk_drag_anim_destroy (GtkDragAnim *anim)
 static gboolean
 gtk_drag_anim_timeout (gpointer data)
 {
-  GtkWidget *icon_window;
   GtkDragAnim *anim = data;
   GtkDragSourceInfo *info = anim->info;
-  GtkWidget *widget = info->widget;
-  GdkFrameClock *frame_clock = gtk_widget_get_frame_clock (widget);
-  gint64 current_time = gdk_frame_clock_get_frame_time (frame_clock);
+  GtkWidget *icon_window;
+  GdkFrameClock *frame_clock;
+  gint64 current_time;
   int hot_x, hot_y;
-  double f = (current_time - anim->start_time) / (double) ANIM_TIME;
+  double f;
   double t;
 
+  frame_clock = gtk_widget_get_frame_clock (info->widget);
+
+  if (!frame_clock)
+    return G_SOURCE_REMOVE;
+
+  current_time = gdk_frame_clock_get_frame_time (frame_clock);
+
+  f = (current_time - anim->start_time) / (double) ANIM_TIME;
+
   if (f >= 1.0)
     return G_SOURCE_REMOVE;